package com.mall.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
import org.springframework.web.util.WebUtils;

import com.mall.untils.Constants;
import com.mall.untils.HttpClientUtil;
import com.mall.untils.HttpGetUtil;
import com.mall.untils.MapUtil;
import com.mall.untils.RedisUtil;
import com.mall.untils.StringUtil;
import com.mall.web.service.UserService;
/**
 * 首页
 *
 */
@Controller
public class IndexController {
	Logger logger = LoggerFactory.getLogger(IndexController.class);
	@Resource UserService userService;
	
	
	/**
     * 获取opendId之后的页面
     *
     * @return
     */
    @RequestMapping(value = "/web_index_go")
    public ModelAndView web_index_go(HttpServletRequest request, ModelMap modelMap,HttpServletResponse response) {
        Map<String, Object> paraMap = WebUtils.getParametersStartingWith(request, "");
        String code = MapUtils.getString(paraMap, "code");
        logger.info("for trace code====>" + code);
        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + Constants.appid + "&secret=" + Constants.secret + "&code=" + code + "&grant_type=authorization_code";
        String res = HttpGetUtil.getStringByGet(url);
        JSONObject jsonObject = JSONObject.fromObject(res);
        String openId = (String) jsonObject.get("openid");
		return new ModelAndView(new RedirectView("web_index?open_id="+openId));
    }
	
	
	/**
	 * 首页
	 * @param request
	 * @param modelMap
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/web_index")
	public String web_index(HttpServletRequest request, ModelMap modelMap,HttpServletResponse response) {
		
		Map<String, Object> paraMap = WebUtils.getParametersStartingWith(request, "");
    	String open_id = MapUtil.getStringValue(paraMap, "open_id");
    	int page_type = MapUtil.getIntValue(paraMap, "page_type");
    	modelMap.addAttribute("open_id", open_id);
		Map<String, Object> wxUserOpenId = userService.getWXUserOpenId(open_id);
		String phone = MapUtil.getStringValue(wxUserOpenId, "phone");
		if(StringUtils.isEmpty(phone)){
			return "redirect:/web_register";
		}
		modelMap.addAttribute("page_type", page_type);
		
		String user_type = MapUtil.getStringValue(paraMap, "user_type");
		String user_id = MapUtil.getStringValue(paraMap, "type_flag_id");
		if(StringUtils.isEmpty(user_type) || StringUtils.isEmpty(user_id)){
			user_id = MapUtil.getStringValue(wxUserOpenId, "user_id");
			user_type = MapUtil.getStringValue(wxUserOpenId, "user_type");
		}else{
			modelMap.addAttribute("type_flag_id", user_id);
		}
		
		List<NameValuePair> params=new ArrayList<NameValuePair>();
		String skip_name="";
		Map<String, Object> map=new HashMap<String, Object>();
		modelMap.addAttribute("footNavigation", 1);
		if(user_type.equals("1")){//家长
			params.add(new BasicNameValuePair("userid",user_id));
			//宝宝信息
			String json_data ="";
			String get_user_api = RedisUtil.getRedisObject("get_user_api"+user_id);
			if(!StringUtils.isEmpty(get_user_api)){
				json_data=get_user_api;
			}else{
				json_data=HttpClientUtil.get(Constants.php_url+"get_user_api.php", params);
				RedisUtil.setRedisObject("get_user_api"+user_id, json_data);
			}
			JSONObject json_fromObject = JSONObject.fromObject(json_data);
			String ser_number = String.valueOf(json_fromObject.get("ser_number"));
			map.put("ser_number", ser_number);
			String baby_name = String.valueOf(json_fromObject.get("baby_name"));
			map.put("baby_name", baby_name);
			String school_name = String.valueOf(json_fromObject.get("school_name"));
			map.put("school_name", school_name);
			String class_name = String.valueOf(json_fromObject.get("class_name"));
			map.put("class_name", class_name);
			String user_img_url = String.valueOf(json_fromObject.get("img"));
			map.put("user_img_url", user_img_url);
			if(page_type==0){//测评结果
				//多元智能测评
				String get_report_api = RedisUtil.getRedisObject("get_report_api"+user_id);
				if(!StringUtils.isEmpty(get_report_api)){
					json_data=get_report_api;
				}else{
					json_data = HttpClientUtil.get(Constants.php_url+"get_report_api.php", params);
					RedisUtil.setRedisObject("get_report_api"+user_id, json_data);
				}
				json_fromObject = JSONObject.fromObject(json_data);
				String renzhi = String.valueOf(json_fromObject.get("renzhi"));
				map.put("renzhi", renzhi);
				String yuyan = String.valueOf(json_fromObject.get("yuyan"));
				map.put("yuyan", yuyan);
				String dayundong = String.valueOf(json_fromObject.get("dayundong"));
				map.put("dayundong", dayundong);
				String jingxidongzuo = String.valueOf(json_fromObject.get("jingxidongzuo"));
				map.put("jingxidongzuo", jingxidongzuo);
				String shejiao = String.valueOf(json_fromObject.get("shejiao"));
				map.put("shejiao", shejiao);
				String zili = String.valueOf(json_fromObject.get("zili"));
				map.put("zili", zili);
				String shuxue = String.valueOf(json_fromObject.get("shuxue"));
				map.put("shuxue", shuxue);
				String yishu = String.valueOf(json_fromObject.get("yishu"));
				map.put("yishu", yishu);
				//八大能力分值
				
				String get_report_msg_api =RedisUtil.getRedisObject("get_report_msg_api"+user_id);
				if(!StringUtils.isEmpty(get_report_msg_api)){
					json_data=get_report_msg_api;
				}else{
					json_data = HttpClientUtil.get(Constants.php_url+"get_report_msg_api.php", params);
					RedisUtil.setRedisObject("get_report_msg_api"+user_id, json_data);
				}
				JSONArray fromObject = JSONArray.fromObject(json_data);
				/**
				 *  css样式
				 *  renzhi  --认知
				 *	language--语言
				 *	independent--自理
				 *	Big-movement--大运动
				 *	action--动作
				 *	art--艺术
				 *	math--数学
				 *	social-contact--社交
				 */
				List<Map<String, Object>> list_map=new ArrayList<Map<String,Object>>();
				List<Map<String, Object>> duplicate_removal_list=new ArrayList<Map<String,Object>>();
				String type_name="";
				for (Iterator iterator = fromObject.iterator(); iterator.hasNext();) {
					JSONObject  json_object = (JSONObject) iterator.next();
					Map<String, Object> map_json=new HashMap<String, Object>();
					String training = String.valueOf(json_object.get("training"));
					if(training.equals("认知能力")){
						map_json.put("type_css", "renzhi");
					}else if(training.equals("语言能力")){
						map_json.put("type_css", "language");
					}else if(training.equals("大运动能力")){
						map_json.put("type_css", "Big-movement");
					}else if(training.equals("精细动作")){
						map_json.put("type_css", "action");
					}else if(training.equals("社交能力")){
						map_json.put("type_css", "social-contact");
					}else if(training.equals("数学能力")){
						map_json.put("type_css", "math");
					}else if(training.equals("艺术能力")){
						map_json.put("type_css", "art");
					}else if(training.equals("自理能力")){
						map_json.put("type_css", "independent");
					}
					map_json.put("training", training);
					String answer = String.valueOf(json_object.get("answer"));
					map_json.put("answer", answer);
					String suggest = String.valueOf(json_object.get("suggest"));
					map_json.put("suggest", suggest);
					
					String title = String.valueOf(json_object.get("title"));
					map_json.put("title", title);
					
					if(!training.equals(type_name)){	
						duplicate_removal_list.add(map_json);
					}
					type_name=training;
					list_map.add(map_json);
				}
				
				modelMap.addAttribute("map", map);
				modelMap.addAttribute("duplicate_removal_list", duplicate_removal_list);
				modelMap.addAttribute("list_map", list_map);
				skip_name="web_index_cpresult";
			}else if(page_type==1){//横向统计
				String get_evaluation_api =null;//  RedisUtil.getRedisObject("get_evaluation_api"+user_id);
				if(!StringUtils.isEmpty(get_evaluation_api)){
					json_data=get_evaluation_api;
				}else{
					json_data = HttpClientUtil.get(Constants.php_url+"get_evaluation_api.php", params);
					RedisUtil.setRedisObject("get_evaluation_api"+user_id, json_data);
				}
				json_fromObject = JSONObject.fromObject(json_data);
				String low_score_total = String.valueOf(json_fromObject.get("low_score_total"));//宝宝自己的人数
				map.put("low_score_total", low_score_total);
				
				String baby_score = String.valueOf(json_fromObject.get("score_baby"));//宝宝自己的人数
				JSONArray fromObject = JSONArray.fromObject(baby_score);
				for (Iterator iterator = fromObject.iterator(); iterator.hasNext();) {
					JSONObject  json_object = (JSONObject) iterator.next();
					String ability_new = String.valueOf(json_object.get("ability"));
					String score = String.valueOf(json_object.get("score"));
					map.put(ability_new, score);
				}
				
				
				baby_score = String.valueOf(json_fromObject.get("baby_score"));//宝宝自己的人数
				fromObject = JSONArray.fromObject(baby_score);
				for (Iterator iterator = fromObject.iterator(); iterator.hasNext();) {
					JSONObject  json_object = (JSONObject) iterator.next();
					String ability_new = "test"+String.valueOf(json_object.get("ability"));
					String score = String.valueOf(json_object.get("score"));
					map.put(ability_new, score);
				}
				
				

				String ability = String.valueOf(json_fromObject.get("ability"));//相应能力分数所对应的人数
				JSONObject ability_json = JSONObject.fromObject(ability);
				map.put("p_ba", String.valueOf(ability_json.get("8p")));
				map.put("p_qi", String.valueOf(ability_json.get("7p")));
				map.put("p_liu", String.valueOf(ability_json.get("6p")));
				map.put("p_wu", String.valueOf(ability_json.get("5p")));
				map.put("p_si", String.valueOf(ability_json.get("4p")));
				map.put("p_san", String.valueOf(ability_json.get("3p")));
				map.put("p_er", String.valueOf(ability_json.get("2p")));
				String examine = String.valueOf(json_fromObject.get("examine"));
				fromObject = JSONArray.fromObject(examine);
				for (Iterator iterator = fromObject.iterator(); iterator.hasNext();) {
					JSONObject  json_object = (JSONObject) iterator.next();
					String training = String.valueOf(json_object.get("training"));
					String sum = String.valueOf(json_object.get("sum"));
					if(training.equals("大运动能力")){
						map.put("dayundong_new", sum);
					}else if(training.equals("数学能力")){
						map.put("shuxue_new", sum);
					}else if(training.equals("社交能力")){
						map.put("shejiao_new", sum);
					}else if(training.equals("精细动作")){
						map.put("jingxi_new", sum);
					}else if(training.equals("自理能力")){
						map.put("zili_new", sum);
					}else if(training.equals("艺术能力")){
						map.put("yishu_new", sum);
					}else if(training.equals("认知能力")){
						map.put("renzhi_new", sum);
					}else if(training.equals("语言能力")){
						map.put("yuyan_new", sum);
					}
				}
				modelMap.addAttribute("map", map);
				skip_name="web_ransverse_statistics";
			}else if(page_type==2){//发育规律
				
				
				String grow_records_api = RedisUtil.getRedisObject("grow_records_api"+user_id);
				if(!StringUtils.isEmpty(grow_records_api)){
					json_data=grow_records_api;
				}else{
					json_data = HttpClientUtil.get(Constants.php_url+"grow_records_api.php", params);
					RedisUtil.setRedisObject("grow_records_api"+user_id, json_data);
				}
				
				json_fromObject = JSONObject.fromObject(json_data);
				int page_type_two = MapUtil.getIntValue(paraMap, "page_type_two");
				modelMap.addAttribute("page_type_two", page_type_two);
				
				JSONObject json_records = JSONObject.fromObject(String.valueOf(json_fromObject.get("records")));
				map.put("created_at", json_records.get("created_at"));
				map.put("height", json_records.get("height"));//自己宝贝
				map.put("weight", json_records.get("weight"));
				map.put("head_circumference", json_records.get("head_circumference"));
				map.put("bust", json_records.get("bust"));
				
				json_records = JSONObject.fromObject(String.valueOf(json_fromObject.get("pattern")));
				map.put("height_pattern", json_records.get("height"));//标准
				map.put("weight_pattern", json_records.get("weight"));
				map.put("head_circumference_pattern", json_records.get("head"));
				map.put("bust_pattern", json_records.get("bust"));
				
				json_records = JSONObject.fromObject(String.valueOf(json_fromObject.get("result")));
				map.put("height_result", json_records.get("height"));//测评结果
				map.put("weight_result", json_records.get("weight"));
				map.put("head_result", json_records.get("head"));
				map.put("bust_result", json_records.get("bust"));
				
				modelMap.addAttribute("map", map);
				if(page_type_two==0){
					skip_name="web_growth_rule";
				}else if(page_type_two==1){
					skip_name="web_jz_growth_weight";
				}else if(page_type_two==2){
					skip_name="web_jz_growth_head";
				}else if(page_type_two==3){
					skip_name="web_jz_growth_chest";
				}
			}
		}else if(user_type.equals("2")){//老师

			params.add(new BasicNameValuePair("tid",user_id));
			//宝宝信息
			String json_data ="";
			
			String get_teacher_api = RedisUtil.getRedisObject("get_teacher_api"+user_id);
			if(!StringUtils.isEmpty(get_teacher_api)){
				json_data=get_teacher_api;
			}else{
				json_data=HttpClientUtil.get(Constants.php_url+"get_teacher_api.php", params);
				RedisUtil.setRedisObject("get_teacher_api"+user_id, json_data);
			}
			
			JSONObject json_fromObject = JSONObject.fromObject(json_data);
			String school_name = String.valueOf(json_fromObject.get("school_name"));
			map.put("school_name", school_name);
			String class_name = String.valueOf(json_fromObject.get("class_name"));
			map.put("class_name", class_name);
			String img = String.valueOf(json_fromObject.get("img"));
			map.put("head_img_url", img);
			if(page_type==0){//测评结果	
				
				String get_eval_results_api = RedisUtil.getRedisObject("get_eval_results_api"+user_id);
				if(!StringUtils.isEmpty(get_eval_results_api)){
					json_data=get_eval_results_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_eval_results_api.php", params);
					RedisUtil.setRedisObject("get_eval_results_api"+user_id, json_data);
				}
				json_fromObject = JSONObject.fromObject(json_data);
				
				
				
				String renzhi = String.valueOf(json_fromObject.get("renzhi"));
				JSONObject jsonObject = JSONObject.fromObject(renzhi);
				String good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("renzhi_good", jsonObject.get("good"));
				}
				
				String bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("renzhi_bad", jsonObject.get("bad"));
				}
				
				String yuyan = String.valueOf(json_fromObject.get("yuyan"));
				jsonObject = JSONObject.fromObject(yuyan);
				
				good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("yuyan_good", jsonObject.get("good"));
				}
				bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("yuyan_bad", jsonObject.get("bad"));
				}
				
				String yundong = String.valueOf(json_fromObject.get("yundong"));
				jsonObject = JSONObject.fromObject(yundong);
				
				good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("yundong_good", jsonObject.get("good"));
				}
				bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("yundong_bad", jsonObject.get("bad"));
				}
				
				String jingxi = String.valueOf(json_fromObject.get("jingxi"));
				jsonObject = JSONObject.fromObject(jingxi);
				
				good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("jingxi_good", jsonObject.get("good"));
				}
				bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("jingxi_bad", jsonObject.get("bad"));
				}
				
				String shejiao = String.valueOf(json_fromObject.get("shejiao"));
				jsonObject = JSONObject.fromObject(shejiao);
				
				good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("shejiao_good", jsonObject.get("good"));
				}
				
				bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("shejiao_bad", jsonObject.get("bad"));
				}
				
				
				String zili = String.valueOf(json_fromObject.get("zili"));
				jsonObject =  JSONObject.fromObject(zili);
				
				good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("zili_good", jsonObject.get("good"));
				}
				
				bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("zili_bad", jsonObject.get("bad"));
				}
				
				String shuxue = String.valueOf(json_fromObject.get("shuxue"));
				jsonObject =  JSONObject.fromObject(shuxue);
				good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("shuxue_good", jsonObject.get("good"));
				}
				bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("shuxue_bad", jsonObject.get("bad"));
				}
				
				String yishu = String.valueOf(json_fromObject.get("yishu"));
				jsonObject =  JSONObject.fromObject(yishu);
				good_str = String.valueOf(jsonObject.get("good"));
				if(!good_str.equals("[\"\"]")){
					modelMap.addAttribute("yishu_good", jsonObject.get("good"));
				}
				bad_str = String.valueOf(jsonObject.get("bad"));
				if(!bad_str.equals("[\"\"]")){
					modelMap.addAttribute("yishu_bad", jsonObject.get("bad"));
				}
				
				
				String word = MapUtil.getStringValue(paraMap, "word");
				if(!StringUtils.isEmpty(word)){
					word=StringUtil.getByteToString(word);
					modelMap.addAttribute("word", word);
				}else{
					word=null;
				}
				params.add(new BasicNameValuePair("word",word));
				
				json_data = HttpClientUtil.get(Constants.php_url+"get_baby_t_api.php", params);
				JSONArray fromObject = JSONArray.fromObject(json_data);
				
				modelMap.addAttribute("list_map", fromObject);
				modelMap.addAttribute("map", map);
				skip_name="web_teacher_test";
			}else if(page_type==1){//横向统计
				String get_eval_t_api = RedisUtil.getRedisObject("get_eval_t_api"+user_id);
				if(!StringUtils.isEmpty(get_eval_t_api)){
					json_data=get_eval_t_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_eval_t_api.php", params);
					RedisUtil.setRedisObject("get_eval_t_api"+user_id, json_data);
				}
				json_fromObject = JSONObject.fromObject(json_data);
				map.put("p_ba", String.valueOf(json_fromObject.get("8p")));
				map.put("p_qi", String.valueOf(json_fromObject.get("7p")));
				map.put("p_liu", String.valueOf(json_fromObject.get("6p")));
				map.put("p_wu", String.valueOf(json_fromObject.get("5p")));
				map.put("p_si", String.valueOf(json_fromObject.get("4p")));
				map.put("p_san", String.valueOf(json_fromObject.get("3p")));
				map.put("p_er", String.valueOf(json_fromObject.get("2p")));
				
				String get_radar_t_api =RedisUtil.getRedisObject("get_radar_t_api"+user_id);
				if(!StringUtils.isEmpty(get_radar_t_api)){
					json_data=get_radar_t_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_radar_t_api.php", params);
					RedisUtil.setRedisObject("get_radar_t_api"+user_id, json_data);
				}

				json_fromObject = JSONObject.fromObject(json_data);
				map.put("get_radar_t_api", String.valueOf(json_fromObject.get("round")));
				
				modelMap.addAttribute("map", map);
				skip_name="web_teacher_statistics";
			}else if(page_type==2){//生长指标
				
				String get_baby_height_api = RedisUtil.getRedisObject("get_baby_height_api"+user_id);
				if(!StringUtils.isEmpty(get_baby_height_api)){
					json_data=get_baby_height_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_baby_height_api.php", params);
					RedisUtil.setRedisObject("get_baby_height_api"+user_id, json_data);
				}
				
				JSONArray fromObject = JSONArray.fromObject(json_data);
				modelMap.addAttribute("list_baby_height", fromObject);
				
				
				String get_baby_weight_api = RedisUtil.getRedisObject("get_baby_weight_api"+user_id);
				if(!StringUtils.isEmpty(get_baby_weight_api)){
					json_data=get_baby_weight_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_baby_weight_api.php", params);
					RedisUtil.setRedisObject("get_baby_weight_api"+user_id, json_data);
				}
				
				fromObject = JSONArray.fromObject(json_data);
				modelMap.addAttribute("list_baby_weight", fromObject);
				
				String get_baby_head_api = RedisUtil.getRedisObject("get_baby_head_api"+user_id);
				if(!StringUtils.isEmpty(get_baby_head_api)){
					json_data=get_baby_head_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_baby_head_api.php", params);
					RedisUtil.setRedisObject("get_baby_head_api"+user_id, json_data);
				}
				

				fromObject = JSONArray.fromObject(json_data);
				modelMap.addAttribute("list_baby_head", fromObject);
				
				String get_baby_bust_api = RedisUtil.getRedisObject("get_baby_bust_api"+user_id);
				if(!StringUtils.isEmpty(get_baby_bust_api)){
					json_data=get_baby_bust_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_baby_bust_api.php", params);
					RedisUtil.setRedisObject("get_baby_bust_api"+user_id, json_data);
				}

				fromObject = JSONArray.fromObject(json_data);
				modelMap.addAttribute("list_baby_bust", fromObject);
				
				
				String get_eval_time_api = RedisUtil.getRedisObject("get_eval_time_api"+user_id);
				if(!StringUtils.isEmpty(get_eval_time_api)){
					json_data=get_eval_time_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_eval_time_api.php", params);
					RedisUtil.setRedisObject("get_eval_time_api"+user_id, json_data);
				}
				map.put("eval_time", StringUtil.getByteToString(String.valueOf(JSONObject.fromObject(json_data).get("eval_time"))));
				
				
				modelMap.addAttribute("map", map);
				skip_name="web_teacher_zhibiao";
			}
		}else if(user_type.equals("99")){//园长
			
			params.add(new BasicNameValuePair("kindergarten_id",user_id ));
			
			
			String json_data = "";
			
			
			String get_enchou_api = RedisUtil.getRedisObject("get_enchou_api"+user_id);
			if(!StringUtils.isEmpty(get_enchou_api)){
				json_data=get_enchou_api;
			}else{
				json_data=HttpClientUtil.get(Constants.php_url+"get_enchou_api.php", params);
				RedisUtil.setRedisObject("get_enchou_api"+user_id, json_data);
			}
			
			JSONObject json_fromObject = JSONObject.fromObject(json_data);
			String kindergarten_name = String.valueOf(json_fromObject.get("kindergarten_name"));
			String img = String.valueOf(json_fromObject.get("img"));
			map.put("head_img_url", img);
			map.put("kindergarten_name", kindergarten_name);
			if(page_type==0){//招生
				/*modelMap.addAttribute("map", map);
				skip_name="web_cp_leader_recruit";
			}else if(page_type==1){//统计
*/				
				String name = MapUtil.getStringValue(paraMap, "name");
				if(!StringUtils.isEmpty(name)){
					name=StringUtil.getByteToString(name);
					params.add(new BasicNameValuePair("name",name));
					modelMap.addAttribute("name", name);
				}
				
				json_data = HttpClientUtil.get(Constants.php_url+"get_enchou_count_api.php", params);
				json_fromObject = JSONObject.fromObject(json_data);
				
				
				String total_number = String.valueOf(json_fromObject.get("total_number"));
				map.put("total_number", total_number);
				
				String baby_number = String.valueOf(json_fromObject.get("baby_number"));
				map.put("baby_number", baby_number);
				
				String list_class = String.valueOf(json_fromObject.get("list_class"));
				map.put("list_class", JSONArray.fromObject(list_class));
				
				json_data = HttpClientUtil.get(Constants.php_url+"get_enchou_class_api.php", params);
				JSONArray fromObject = JSONArray.fromObject(json_data);
				
				modelMap.addAttribute("class_list", fromObject);

				JSONObject  json_obj = (JSONObject)fromObject.get(2);
				
				int class_id = MapUtil.getIntValue(paraMap, "class_id");
				if(class_id!=0){
					params.add(new BasicNameValuePair("tid",String.valueOf(class_id)));
					modelMap.addAttribute("class_id", class_id);
				}else{
					params.add(new BasicNameValuePair("tid",String.valueOf(json_obj.get("class_id"))));
					modelMap.addAttribute("class_id", String.valueOf(json_obj.get("class_id")));
				}
				
				String get_enchou_column_api =RedisUtil.getRedisObject("get_eval_t_api"+class_id);
				if(!StringUtils.isEmpty(get_enchou_column_api)){
					json_data=get_enchou_column_api;
				}else{
					json_data = HttpClientUtil.get(Constants.php_url+"get_eval_t_api.php", params);
					RedisUtil.setRedisObject("get_eval_t_api"+class_id, json_data);
				}
				json_fromObject = JSONObject.fromObject(json_data);
				map.put("p_ba", String.valueOf(json_fromObject.get("8p")));
				map.put("p_qi", String.valueOf(json_fromObject.get("7p")));
				map.put("p_liu", String.valueOf(json_fromObject.get("6p")));
				map.put("p_wu", String.valueOf(json_fromObject.get("5p")));
				map.put("p_si", String.valueOf(json_fromObject.get("4p")));
				map.put("p_san", String.valueOf(json_fromObject.get("3p")));
				map.put("p_er", String.valueOf(json_fromObject.get("2p")));
				
				
				modelMap.addAttribute("map", map);
				skip_name="web_cp_leader_statistics";
			}else if(page_type==2){//管理
				params.add(new BasicNameValuePair("kindergarten_id",user_id));
				
				String get_enchou_ability_api = RedisUtil.getRedisObject("get_enchou_ability_api"+user_id);
				if(!StringUtils.isEmpty(get_enchou_ability_api)){
					json_data=get_enchou_ability_api;
				}else{
					json_data=HttpClientUtil.get(Constants.php_url+"get_enchou_ability_api.php", params);
					RedisUtil.setRedisObject("get_enchou_ability_api"+user_id, json_data);
				}

				json_fromObject = JSONObject.fromObject(json_data);
				
				map.put("json_fromObject", json_fromObject);
				
				
				modelMap.addAttribute("map", map);
				skip_name="web_cp_leader_manage";
			}
		}
		return skip_name;
	}
	
	
	
	
}
